//
//  GetSpotSuggestTask.m
//  ZooNgonDoiOS
//
//  Created by Anh Jun Linh Tinh on 7/4/12.
//  Copyright (c) 2012 Personal. All rights reserved.
//

#import "GetSpotSuggestTask.h"

@implementation GetSpotSuggestTask
-(id)initWithParams:(NSString *)search_condition{
    self = [self initWithParams:search_condition limit:0];
    return self;
}

-(id)initWithParams:(NSString *)search_condition limit:(int)limit{
    self = [super init];
    if(self){
        _limit = limit;
        _search_condition = search_condition;
    }
    return  self;
}

-(void)doExecute{
    NSMutableArray *arrayKeys = [[NSMutableArray alloc] init];
    NSMutableArray *arrayValues = [[NSMutableArray alloc] init];
    
    [arrayKeys addObject:@"name"];
    [arrayValues addObject:_search_condition];
    if(_limit > 0){
        [arrayKeys addObject:@"limit"];
         NSString* strLimit = [NSString stringWithFormat:@"%i", _limit];
        [arrayValues addObject:strLimit];
    }
    NSDictionary *params = [NSDictionary dictionaryWithObjects:arrayValues forKeys:arrayKeys];
    [[RKObjectManager sharedManager].client get:@"/spot/suggest" queryParameters:params delegate:self];
}

-(void)request:(RKRequest *)request didFailLoadWithError:(NSError *)error{
    
}

-(void)request:(RKRequest *)request didLoadResponse:(RKResponse *)response{
    
}

@end
